package Task7;

import java.util.Scanner;
import java.util.Stack;

public class Main2 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        int length = str.length();
        boolean ret = chkParenthesis(str,length);
        System.out.println(ret);
    }

    private static boolean chkParenthesis(String str, int length) {
        Stack<Character> stack = new Stack<>();
        int i = 0;
//        ||!stack.empty()
        while (i < length){
            if(str.charAt(0) == ')' || str.charAt(0) != '('){
                return false;
            }
            if (str.charAt(i) == '(') {
                stack.push(str.charAt(i));
            }else if(str.charAt(i) == ')'){
                if(stack.empty()){
                    stack.push(str.charAt(i));
                }else if(stack.peek()== '(') {
                    stack.pop();
                }
                //stack.push(str.charAt(i));
            }else{
                return false;
            }
            i++;
        }
        if(stack.empty()){
            return true;
        }else {
            return false;
        }

    }
}
